package com.jimmy.medical.entity;

import javax.persistence.*;
import java.util.Set;
import java.util.TreeSet;

/**
 * @author jimmy
 * @Desc: 订单类型
 * @date 2018-04-03
 */
@Entity
@Table(name = "order_type")
public class OrderType extends AbstractEntity {

    /**
     * 类型名称
     */
    @Column(name = "type_name")
    private String typeName;

    /**
     * 类型代码
     */
    @Column(name = "type_code")
    private String typeCode;

    /**
     * 包含的工单
     */
    @ManyToMany(cascade = {CascadeType.REMOVE}, fetch = FetchType.EAGER)
    @JoinTable(name = "order_type_flow_order_type", joinColumns = {@JoinColumn(name = "order_type_id", referencedColumnName = "id")}, inverseJoinColumns = {@JoinColumn(name = "flow_order_type_id", referencedColumnName = "id")})
    @OrderBy("typeOrder asc")
    private Set<FlowOrderType> flowOrderTypes = new TreeSet<FlowOrderType>();

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public String getTypeCode() {
        return typeCode;
    }

    public void setTypeCode(String typeCode) {
        this.typeCode = typeCode;
    }

    public Set<FlowOrderType> getFlowOrderTypes() {
        return flowOrderTypes;
    }

    public void setFlowOrderTypes(Set<FlowOrderType> flowOrderTypes) {
        this.flowOrderTypes = flowOrderTypes;
    }
}
